/*
 * Copyright 2008-2012 Centro Andaluz de Innovación y Tecnologías de la
 * Información y las Comunicaciones (CITIC). All Rights Reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
 *
 * Please contact CITIC - Edificio CITIC, C/ Marie Curie, 6 Parque
 * Tecnológico de Andalucía 29590 - Campanillas, Málaga, Spain
 * or visit www.citic.es, if you need additional information or
 * have any questions.
 */

package es.citic.puedes.youtube.testhelp;


import org.junit.Assert;

import es.citic.puedes.youtube.IYouTubeManager;
import es.citic.puedes.youtube.YouTubeAuthException;
import es.citic.puedes.youtube.YouTubeException;
import es.citic.puedes.youtube.bbdd.YouTubeDataBase;
import es.citic.puedes.youtube.impl.YouTubeManagerImpl;
import es.citic.puedes.youtube.test.YouTubeManagerTest;

public class YouTubeAccessTest {
	public static YouTubeManagerImpl runYouTubeAccessTest(String configFile, YouTubeDataBase dataBase) {
		return (new YouTubeManagerImpl(configFile, dataBase));
	}

	public static void runYouTubeRegisterUserTest(IYouTubeManager ytm, Integer userId, String username, String pass) throws SecurityException, YouTubeException, YouTubeAuthException {		
		// registers an user
		System.out.println("registers user.. ");
		ytm.registreUser(userId, username, pass);
	}

	public static void runYouTubeModifyUserTest(IYouTubeManager ytm, Integer userId, String username, String pass) throws SecurityException, YouTubeException, YouTubeAuthException {		
		// modifies an user
		try {
			ytm.registreUser(userId, username, pass);
		} catch (Exception e) {
			// Nothing to do
		}
		
		try {
			ytm.changeUser(userId, username, "foo");
			Assert.fail();
		} catch (Exception e) {
			// Nothing to do
		}		
	}

	public static void runYouTubeDeleteUserTest(IYouTubeManager ytm, Integer userId) throws SecurityException, YouTubeException, YouTubeAuthException {	
		// deletes an user
		System.out.println("delete user.. ");
		try {
			ytm.registreUser(userId, YouTubeManagerTest.username, YouTubeManagerTest.pass);
		} catch (Exception e) {
			// Nothing to do
		}	
				
		ytm.deleteUser(userId);
	}
}
